//
//  oneViewController.swift
//  demo3
//
//  Created by zaizai on 2018/5/30.
//  Copyright © 2018年 guest. All rights reserved.
//

import UIKit
import  Foundation
class oneViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "第一页"
        
        setNormalNavigation()
        setImageWithColorNavigation(image: getImageWithColor(color: UIColor("#EEEEEE")!))
        view.backgroundColor = UIColor("#0077ED")
//            HEXColor(hexValue: 0x0077ED)

        let dict1 = ["name": "mary", "age": "18","name1": "(null)", "age1": ""]
        DLog(dict1)
        let dict2  = dddd(ssss: dict1)
       
        DLog("====eee45555==\(dict2)=====")
       
        
        DLog(BaseUrl)
        DLog("======9999======\(BaseUrl)=================")
        
       
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) {
             CLLProgressHUD.show()
        }

        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 8) {
             CLLProgressHUD.dismiss()
        }

        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {
             CLLProgressHUD.showMessages(text: "正在加载")
        }
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 8) {
             CLLProgressHUD.showInfo("温馨提示")

        }


        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 12) {
             CLLProgressHUD.showToast(text: "正在加载正在加载")

        }
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 15) {
//                    CLLProgressHUD.showSuccessMessage("成功")
            CLLProgressHUD.showSuccessMessage("成功", view: self.view)
        }
        
    }
    deinit {
        DLog("=====343434=====\(self)=====")
    }
   
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
       let nav = BaseNavigationController.init(rootViewController:TwoViewController.init())
        nav.modalPresentationStyle = UIModalPresentationStyle(rawValue: 0)!
        present(nav, animated: true, completion: nil)
//        self.elAlert(title: "温馨提示", message: "\n请在确认收到货品后确认", buttons: ["取消", "确认"]) {[weak self] (index) in
//            if index == 1 {
//               let nav = BaseNavigationController.init(rootViewController:TwoViewController.init())
//                nav.modalPresentationStyle = UIModalPresentationStyle(rawValue: 0)!
//                self?.present(nav, animated: true, completion: nil)
//            }
//        }
        
//     elAlert(title: "支付成功", message: "在商户中心可以查看订单信息", buttons: ["知道了"], tapped: { [weak self](_) in
//                let nav = BaseNavigationController.init(rootViewController:TwoViewController.init())
//                    nav.modalPresentationStyle = UIModalPresentationStyle(rawValue: 0)!
//                self?.present(nav, animated: true, completion: nil)
//                })

    }
}
extension oneViewController {
    func dddd(ssss: [String : Any]) -> [String : Any] {
        var newDict: [String : Any]
        newDict = ssss
        for vvv in newDict.keys {
            if CLLStringIsEmpty(value: newDict[vvv] as AnyObject) {
                newDict.removeValue(forKey: vvv)
            }
        }
        
      return newDict
    }
    
    
    
    
    func CLLStringIsEmpty(value: AnyObject?) -> Bool {
        //首先判断是否为nil
        if (nil == value) {
            //对象是nil，直接认为是空串
            return true
        }else{
            //然后是否可以转化为String
            if let myValue  = value as? String{
                //然后对String做判断
                return myValue == "" || myValue == "(null)" || 0 == myValue.count
            }else{
                //字符串都不是，直接认为是空串
                return true
            }
        }
    }
    
}
